package com.huawei.hms.support.api.sns.json;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import com.huawei.hms.api.Api;
import com.huawei.hms.api.HuaweiApiAvailability;
import com.huawei.hms.common.HuaweiApi;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.api.entity.sns.UnreadMsg;
import com.huawei.hms.support.api.entity.sns.UserUnreadMsg;
import com.huawei.hms.support.api.entity.sns.internal.AddFriendReq;
import com.huawei.hms.support.api.entity.sns.internal.AddFriendResp;
import com.huawei.hms.support.api.entity.sns.internal.FriendSelectorIntentReq;
import com.huawei.hms.support.api.entity.sns.internal.GetContactSelectorIntentReq;
import com.huawei.hms.support.api.entity.sns.internal.GetFriendListResp;
import com.huawei.hms.support.api.entity.sns.internal.GetGroupListResp;
import com.huawei.hms.support.api.entity.sns.internal.GetGroupMemListResp;
import com.huawei.hms.support.api.entity.sns.internal.GetIMStatusResp;
import com.huawei.hms.support.api.entity.sns.internal.GroupListReq;
import com.huawei.hms.support.api.entity.sns.internal.GroupMemListReq;
import com.huawei.hms.support.api.entity.sns.internal.GroupSelectorIntentReq;
import com.huawei.hms.support.api.entity.sns.internal.SnsNaming;
import com.huawei.hms.support.api.entity.sns.internal.SnsSendMsgIntentReq;
import com.huawei.hms.support.api.entity.sns.internal.UiIntentReq;
import com.huawei.hms.support.api.entity.sns.internal.UserDataReq;
import com.huawei.hms.support.api.entity.sns.internal.UserDataResp;
import com.huawei.hms.support.api.entity.sns.internal.UserSearchReq;
import com.huawei.hms.support.api.entity.sns.internal.UserSearchResp;
import com.huawei.hms.support.api.entity.sns.internal.UserUnreadMsgReq;
import com.huawei.hms.support.api.entity.sns.json.SnsOutIntent;
import com.huawei.hms.support.api.sns.json.SnsClient.Callback;
import com.huawei.hms.support.hianalytics.HiAnalyticsClient;
import com.huawei.hms.utils.Checker;
import o.fjo;

public class SnsClientImpl extends HuaweiApi<SnsOptions> implements SnsClient {
    private static final SnsClientBuilder a = new SnsClientBuilder();
    private static final SnsOptions b = new SnsOptions();
    private static final Api<SnsOptions> c = new Api(HuaweiApiAvailability.HMS_API_NAME_SNS);

    SnsClientImpl(Activity activity, SnsOptions snsOptions) {
        super(activity, c, snsOptions, a);
    }

    SnsClientImpl(Context context, SnsOptions snsOptions) {
        super(context, c, snsOptions, a);
    }

    public fjo<SnsOutIntent> getUiIntent(UiIntentReq uiIntentReq, Callback callback) {
        Checker.checkNonNull(uiIntentReq);
        String a = a(SnsNaming.getUiIntent);
        TaskApiCall snsTaskApiCall = new SnsTaskApiCall(SnsNaming.getUiIntent, uiIntentReq.toJsonString(), callback, this);
        a(snsTaskApiCall, a);
        return doWrite(snsTaskApiCall);
    }

    public fjo<SnsOutIntent> sendMsgIntent(SnsSendMsgIntentReq snsSendMsgIntentReq, Callback callback) {
        Checker.checkNonNull(snsSendMsgIntentReq);
        String a = a(SnsNaming.getMsgSendIntent);
        TaskApiCall snsSendMsgTaskApiCall = new SnsSendMsgTaskApiCall(SnsNaming.getMsgSendIntent, snsSendMsgIntentReq.toJsonString(), callback, this);
        a(snsSendMsgTaskApiCall, a);
        return doWrite(snsSendMsgTaskApiCall);
    }

    public fjo<GetFriendListResp> getFriendList(Callback callback) {
        String a = a(SnsNaming.getFriendList);
        TaskApiCall snsGetFriendListTaskApiCall = new SnsGetFriendListTaskApiCall(SnsNaming.getFriendList, "", callback, this);
        a(snsGetFriendListTaskApiCall, a);
        return doWrite(snsGetFriendListTaskApiCall);
    }

    public fjo<SnsOutIntent> getFriendSelectorIntent(FriendSelectorIntentReq friendSelectorIntentReq, Callback callback) {
        Checker.checkNonNull(friendSelectorIntentReq);
        String a = a(SnsNaming.getFriendSelectorIntent);
        TaskApiCall snsTaskApiCall = new SnsTaskApiCall(SnsNaming.getFriendSelectorIntent, friendSelectorIntentReq.toJsonString(), callback, this);
        a(snsTaskApiCall, a);
        return doWrite(snsTaskApiCall);
    }

    public fjo<GetGroupListResp> getGroupList(GroupListReq groupListReq, Callback callback) {
        Checker.checkNonNull(groupListReq);
        String a = a(SnsNaming.getGroupList);
        TaskApiCall snsGetGroupListTaskApiCall = new SnsGetGroupListTaskApiCall(SnsNaming.getGroupList, groupListReq.toJsonString(), callback, this);
        a(snsGetGroupListTaskApiCall, a);
        return doWrite(snsGetGroupListTaskApiCall);
    }

    public fjo<GetGroupMemListResp> getGroupMemList(GroupMemListReq groupMemListReq, Callback callback) {
        Checker.checkNonNull(groupMemListReq);
        String a = a(SnsNaming.getGroupMemList);
        TaskApiCall snsGetGroupMemListTaskApiCall = new SnsGetGroupMemListTaskApiCall(SnsNaming.getGroupMemList, groupMemListReq.toJsonString(), callback, this);
        a(snsGetGroupMemListTaskApiCall, a);
        return doWrite(snsGetGroupMemListTaskApiCall);
    }

    public fjo<UserDataResp> getUserData(UserDataReq userDataReq, Callback callback) {
        Checker.checkNonNull(userDataReq);
        String a = a(SnsNaming.getUserData);
        TaskApiCall snsGetUserDataApiCall = new SnsGetUserDataApiCall(SnsNaming.getUserData, userDataReq.toJsonString(), callback, this);
        a(snsGetUserDataApiCall, a);
        return doWrite(snsGetUserDataApiCall);
    }

    public fjo<UnreadMsg> getUnreadMsgCount(Callback callback) {
        String a = a(SnsNaming.getUnreadMsgCount);
        TaskApiCall snsGetUnReadCountApiCall = new SnsGetUnReadCountApiCall(SnsNaming.getUnreadMsgCount, "", callback, this);
        a(snsGetUnReadCountApiCall, a);
        return doWrite(snsGetUnReadCountApiCall);
    }

    public fjo<UserUnreadMsg> getUserCount(UserUnreadMsgReq userUnreadMsgReq, Callback callback) {
        Checker.checkNonNull(userUnreadMsgReq);
        String a = a(SnsNaming.getUserCount);
        TaskApiCall snsGetUserCountApiCall = new SnsGetUserCountApiCall(SnsNaming.getUserCount, userUnreadMsgReq.toJsonString(), callback, this);
        a(snsGetUserCountApiCall, a);
        return doWrite(snsGetUserCountApiCall);
    }

    public fjo<SnsOutIntent> getGroupSelectorIntent(GroupSelectorIntentReq groupSelectorIntentReq, Callback callback) {
        Checker.checkNonNull(groupSelectorIntentReq);
        String a = a(SnsNaming.getGroupSelectorIntent);
        TaskApiCall snsTaskApiCall = new SnsTaskApiCall(SnsNaming.getGroupSelectorIntent, groupSelectorIntentReq.toJsonString(), callback, this);
        a(snsTaskApiCall, a);
        return doWrite(snsTaskApiCall);
    }

    public fjo<SnsOutIntent> getContactSelectorIntent(GetContactSelectorIntentReq getContactSelectorIntentReq, Callback callback) {
        Checker.checkNonNull(getContactSelectorIntentReq);
        String a = a(SnsNaming.getContactSelectorIntent);
        TaskApiCall snsTaskApiCall = new SnsTaskApiCall(SnsNaming.getContactSelectorIntent, getContactSelectorIntentReq.toJsonString(), callback, this);
        a(snsTaskApiCall, a);
        return doWrite(snsTaskApiCall);
    }

    public fjo<SnsOutIntent> getGroupCreatorIntent(Callback callback) {
        String a = a(SnsNaming.getGroupCreatorIntent);
        TaskApiCall snsTaskApiCall = new SnsTaskApiCall(SnsNaming.getGroupCreatorIntent, "", callback, this);
        a(snsTaskApiCall, a);
        return doWrite(snsTaskApiCall);
    }

    public fjo<AddFriendResp> addFriend(AddFriendReq addFriendReq, Callback callback) {
        Checker.checkNonNull(addFriendReq);
        String a = a(SnsNaming.addFriend);
        TaskApiCall snsAddFriendApiCall = new SnsAddFriendApiCall(SnsNaming.addFriend, addFriendReq.toJsonString(), callback, this);
        a(snsAddFriendApiCall, a);
        return doWrite(snsAddFriendApiCall);
    }

    public fjo<UserSearchResp> searchUser(UserSearchReq userSearchReq, Callback callback) {
        Checker.checkNonNull(userSearchReq);
        String a = a(SnsNaming.addFriend);
        TaskApiCall snsSearchReqApiCall = new SnsSearchReqApiCall(SnsNaming.searchUser, userSearchReq.toJsonString(), callback, this);
        a(snsSearchReqApiCall, a);
        return doWrite(snsSearchReqApiCall);
    }

    public fjo<GetIMStatusResp> getIMStatus(Callback callback) {
        String a = a(SnsNaming.getIMStatus);
        TaskApiCall snsImStateApiCall = new SnsImStateApiCall(SnsNaming.getIMStatus, "", callback, this);
        a(snsImStateApiCall, a);
        return doWrite(snsImStateApiCall);
    }

    private void a(TaskApiCall taskApiCall, String str) {
        if (!TextUtils.isEmpty(str)) {
            taskApiCall.setTransactionId(str);
        }
    }

    private String a(String str) {
        return HiAnalyticsClient.reportEntry(getContext(), str, 30003300);
    }

    public void biReportExit(String str, String str2, int i, int i2) {
        HiAnalyticsClient.reportExit(getContext(), str, str2, i, i2);
    }
}
